﻿using System.Drawing;
using System.Windows.Forms;
using G.Runtime;

namespace GameDesigner.Source.Widgets
{
    class LabelWidget : Widget
    {
        private readonly string _DisplayableName;
        private readonly Control _Control;
        private readonly Point _Point;
        
        public LabelWidget(Control pControl, string name, Point pPoint)
        {
            _Control = pControl;
            _DisplayableName = name;
            _Point = pPoint;
            _Control.Paint += OnPaint;
        }
        
        public override void Dispose() 
        {
            _Control.Paint -= OnPaint;
        }

        public override Point Point
        {
            get { return _Point; }
        }

        protected override void OnPaint(object sender, PaintEventArgs e)
        {
            Font fn = new Font("Comic Sans MS", 12);
            SolidBrush solidBlack = new SolidBrush(Color.Black);
            e.Graphics.DrawString(_DisplayableName, fn, solidBlack, _Point);
        }

    }
}
